home *** CD-ROM | disk | FTP | other *** search
/ Chip 2006 June / CHIP 2006-06.2.iso / program / freeware / ubrowser.exe / ubrowser / ubrowser.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-02-21  |  4.7 KB  |  147 lines

  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  uBrowser - a program that illustrates one way of embedding the
  4. //  Mozilla Gecko (tm) Rendering Engine in an application, grabbing the
  5. //  rendered output and displaying it on the surface of a 3D polygon as
  6. //  texture in an OpenGL (tm) application.
  7. //
  8. //  uBrowser is free software; you can redistribute it and/or modify
  9. //  it under the terms of the GNU General Public License as published by
  10. //  the Free Software Foundation; either version 2 of the License, or
  11. //  (at your option) any later version.
  12. //
  13. //  uBrowser is distributed in the hope that it will be useful,
  14. //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. //  GNU General Public License for more details.
  17. //
  18. //  You should have received a copy of the GNU General Public License
  19. //  along with uBrowser; if not, write to the Free Software
  20. //  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. //
  22. //  Original code:  Copyright 2005 Linden Research Inc.
  23. //                  http://www.lindenlab.com
  24. //
  25. //  Primary author and site maintainer: Callum Prentice (callum@ubrowser.com)
  26. //
  27. //  See contributors.txt or http://ubrowser.com for a list of contributors
  28. //  without whose generous donation of time and effort, this application
  29. //  would not have been possible.
  30. //
  31. ////////////////////////////////////////////////////////////////////////////////
  32. #ifndef UBROWSER_H
  33. #define UBROWSER_H
  34.  
  35. #include <string>
  36. #include <vector>
  37. #include <math.h>
  38.  
  39. #include "GL/glut.h"
  40. #include "glui.h"
  41.  
  42. #include "embeddedbrowser.h"
  43. #include "embeddedbrowserwindow.h"
  44.  
  45. static void gluiCallbackWrapper( int controlIdIn );
  46.  
  47. ////////////////////////////////////////////////////////////////////////////////
  48. //
  49. class uBrowser :
  50.     public embeddedBrowserWindowObserver
  51. {
  52.     public:
  53.         uBrowser();
  54.         ~uBrowser();
  55.  
  56.         bool init( const char* arg0, int appWindowIn );
  57.         bool reset();
  58.         const std::string& getName() { return mName; };
  59.         void reshape( int widthIn, int heightIn );
  60.         void makeChrome();
  61.         void windowPosToTexturePos( int winXIn, int winYIn, int& texXOut, int& texYOut );
  62.         void resetView();
  63.         void drawGeometry( int typeIn );
  64.  
  65.         void display();
  66.         void idle();
  67.         void keyboard( unsigned char keyIn, int xIn, int yIn );
  68.         void passiveMouse( int xIn, int yIn );
  69.         void mouseButton( int button, int state, int xIn, int yIn );
  70.         void mouseMove( int xIn, int yIn );
  71.  
  72.         void setSize( int widthIn , int heightIn );
  73.  
  74.         void gluiCallback( int controlIdIn );
  75.  
  76.         virtual void onNavigateBegin( const EventType& eventIn );
  77.         virtual void onNavigateComplete( const EventType& eventIn );
  78.         virtual void onUpdateProgress( const EventType& eventIn );
  79.         virtual void onStatusTextChange( const EventType& eventIn );
  80.         virtual void onLocationChange( const EventType& eventIn );
  81.  
  82.     private:
  83.         void* getNativeWindowHandle();
  84.         void uBrowser::setFocusNativeWindow();
  85.  
  86.         std::string mName;
  87.         int mAppWindow;
  88.         int mWindowWidth;
  89.         int mWindowHeight;
  90.         int mTextureWidth;
  91.         int mTextureHeight;
  92.         int mBrowserWindowWidth;
  93.         int mBrowserWindowHeight;
  94.         float mTextureScaleX;
  95.         float mTextureScaleY;
  96.         float mViewportAspect;
  97.         float mViewPos[ 3 ];
  98.         float mViewRotation[ 16 ];
  99.         unsigned char mPixelColorRB[ 3 ];
  100.         unsigned char mPixelColorG[ 3 ];
  101.         int mCurMouseX;
  102.         int mCurMouseY;
  103.         GLuint mRedBlueTexture;
  104.         unsigned char mRedBlueTexturePixels[ 256 * 256 * 3 ];
  105.         GLuint mGreenTexture;
  106.         unsigned char mGreenTexturePixels[ 16 * 16 * 3 ];
  107.         GLuint mAppTexture;
  108.         unsigned char* mAppTexturePixels;
  109.         int mCurObjType;
  110.         int mSelBookmark;
  111.         GLUI* mTopGLUIWindow;
  112.         GLUI_Button* mNavBackButton;
  113.         GLUI_Button* mNavStopButton;
  114.         GLUI_Button* mNavForwardButton;
  115.         GLUI* mTop2GLUIWindow;
  116.         GLUI_EditText* mUrlEdit;
  117.         GLUI_String mNavUrl;
  118.         GLUI* mRightGLUIWindow;
  119.         GLUI_Rotation* mViewRotationCtrl;
  120.         GLUI_Translation* mViewScaleCtrl;
  121.         GLUI_Translation* mViewTranslationCtrl;
  122.         GLUI* mBottomGLUIWindow;
  123.         GLUI_StaticText* mStatusText;
  124.         GLUI_StaticText* mProgressText;
  125.         const int mIdReset;
  126.         const int mIdExit;
  127.         const int mIdBookmarks;
  128.         const int mIdTypeNull;
  129.         const int mIdTypeFlat;
  130.         const int mIdTypeBall;
  131.         const int mIdTypeCube;
  132.         const int mIdTypeFlag;
  133.         const int mIdUrlEdit;
  134.         const int mIdNavBack;
  135.         const int mIdNavStop;
  136.         const int mIdNavHome;
  137.         const int mIdNavForward;
  138.         const int mIdBrowserSmall;
  139.         const int mIdBrowserMedium;
  140.         const int mIdBrowserLarge;
  141.         const int mFocusUrlEdit;
  142.         const std::string mHomeUrl;
  143.         std::vector< std::pair< std::string, std::string > > mBookmarks;
  144.         embeddedBrowser* mEmbeddedBrowser;
  145. };
  146.  
  147. #endif // UBROWSER_H